package besteninilkprojesi;

/**
 *
 * @author Gorky
 */
public class Point2D {
    private float x;
    private float y;

    public Point2D(float x, float y) {
        this.x = x;
        this.y = y;
    }

    public float getX() {
        return x;
    }

    public void setX(float x) {
        this.x = x;
    }

    public float getY() {
        return y;
    }

    public void setY(float y) {
        this.y = y;
    }
    
    public float distance(Point2D point2D){
        float distance_x = (point2D.getX() - getX());
        float distance_y = (point2D.getY() - getY());
        float distance_total = (float)Math.sqrt((distance_x*distance_x)+(distance_y*distance_y));
        return distance_total;
    }
    
    public static void main(String[] args) {
        Point2D firstPoint = new Point2D(2, 3);
        Point2D secondPoint = new Point2D(7, 15);
        //System.out.println(firstPoint.x + ":" + firstPoint.y);
        //System.out.println("First point x:"+firstPoint.getX());
        //firstPoint.setX(0.5f);
        //System.out.println("First point x after set:"+firstPoint.getX());
        System.out.println("Distance from first point to second point is " + firstPoint.distance(secondPoint));
    }
}

